package net.model.composite;

import java.util.ArrayList;
import java.util.Iterator;

public class MenuNode extends AbstractMenu {
	
	private ArrayList<IMenu> menuList = new ArrayList<IMenu>();
	
	public MenuNode(String name) {
		this.name = name;
	}

	public void add(IMenu menu) {
		this.menuList.add(menu);
	}
	
	public void remove(IMenu menu) {
		int idx = this.menuList.indexOf(menu);
		if (-1!=idx) {
			this.menuList.remove(idx);
		}
	}
	
	public Iterator createIterator() {
		return new CompositeIterator(menuList.iterator());
	}
	
	public Iterator iterator() {
		return menuList.iterator();
	}
	
	public void print() {
		System.out.println("============="+this.name+"=============");
	}
}
